from pyevent import QThread, Task
from example.job import CrawlJob
import time


def process_tencent_result(crawl_result):
    print(crawl_result)


def main():
    event = QThread('crawlEvent')
    event.start()
    task1 = Task('crawl_sina', CrawlJob(), name='crawlTask1', callback=print)
    event.put(task1)
    task2 = Task('crawl_tencent', CrawlJob(), name='crawlTask2', callback=process_tencent_result)
    event.put(task2)

    time.sleep(2)
    event.pause()
    time.sleep(2)
    event.resume()

    event.stop()
    event.join()


if __name__ == '__main__':
    main()